/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2021-01-23     RT-Thread    first version
 */

#include <rtthread.h>
#include <drivers/pin.h>
#include "drv_common.h"

#define DBG_TAG "main"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>

#define LED_PIN_R   GET_PIN(E, 7)
#define LED_PIN_G   GET_PIN(E, 8)
#define LED_PIN_B   GET_PIN(E, 9)

int main(void)
{
    rt_pin_mode(LED_PIN_R, PIN_MODE_OUTPUT);
    rt_pin_mode(LED_PIN_G, PIN_MODE_OUTPUT);
    rt_pin_mode(LED_PIN_B, PIN_MODE_OUTPUT);

    rt_pin_write(LED_PIN_R, PIN_HIGH);
    rt_pin_write(LED_PIN_G, PIN_HIGH);
    rt_pin_write(LED_PIN_B, PIN_HIGH);

    while (1)
    {
        if (rt_pin_read(LED_PIN_R) == PIN_HIGH) {
            rt_pin_write(LED_PIN_R, PIN_LOW);
        }
        else {
            rt_pin_write(LED_PIN_R, PIN_HIGH);
        }
        rt_thread_mdelay(1000);
    }

    return RT_EOK;
}
